<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../../include/admincontent.jsp" %>
<div id="location">当前位置：首页 > 笔试管理 > 考场管理</div>
<div id="Content">
<%--    <div class="btnbar">
        <button type="button" class="add" id="bsroomadd">添加</button>
        <button type="button" class="edit" id="bsroomedit">修改</button>
        <button type="button" class="del" id="bsroomdel">删除</button>
    </div>--%>
    <div class="toolbars" style="height:30px;white-space:nowrap;width:auto;margin-left: 20px;" totalwidth="314">
        <a id="bsroomadd">
            <em id="add_em" class="ico16 add_new"></em>
            <span id="send_span" class="menu_span" title="添加">添加</span>
        </a>
        <a id="bsroomedit">
            <em class="ico16 editor_16"></em>
            <span class="menu_span" title="修改">修改</span>
        </a>
        <a id="bsroomdel">
            <em class="ico16 del_16"></em>
            <span class="menu_span" title="删除">删除</span>
        </a>
    </div>
    <!-- 筛选条件 -->
    <div id="searchbox" style="margin-top: 10px">
        <form id="sform">
            <table class="treeTable searchform">
                <thead>
                <tr>
                    <td width="120">考场名称：</td>
                    <td width="100">
                        <div><input type="text" name="name"/></div>
                    </td>
                    <td width="120">考场别名：</td>
                    <td width="100">
                        <div><input type="text" name="nickname"/></div>
                    </td>
                    <td width="120">考场状态：</td>
                    <td width="100">
                        <div>
                            <select name="state">
                                <option value="">全部</option>
                                <option value="启用">启用</option>
                                <option value="停用">停用</option>
                            </select>
                        </div>
                    </td>
                    <td width="120">
                        <%--<button id="searchbtn" type="button" class="search"></button>--%>
                            <div class="toolbars">
                                <a id="searchbtn" >
                                    <em class="ico16 search_16"></em>
                                    <span class="menu_span" title="查询">查询</span>
                                </a>
                            </div>
                    </td>
                    <td></td>
                </tr>
                </thead>
            </table>
        </form>
    </div>
    <table class="layui-table" id="tablelist" lay-filter="roomTable">
<%--        <thead>
        <tr>
            <td width="20"><input type="checkbox" class="allcheckbox" title="选择全部/取消全选"/></td>
            <td width="30">序号</td>
            <td width="100">考场名称</td>
            <td width="100">考场别名</td>
            <td width="90">座位开始编号</td>
            <td width="90">有效座位数量</td>
            <td>考场地址</td>
            <td width="50">状态</td>
            <td width="50">优先级</td>
        </tr>
        </thead>
        <tbody id="result"></tbody>--%>
    </table>
    <%--<div id="page"></div>--%>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        //getList();
/*        $('#searchbtn').click(function () {
            //getList();
        });*/

        $("#searchbtn").on('click', function () {

                function fun1() {
                    layui.use('table', () => {
                            tavkeIns.reload({
                                url: "/Do/BS/getroomsLayuiJson",
                                where: {
                                    name: $("input[name = 'name']").val(),
                                    nickname: $("input[name = 'nickname']").val(),
                                    state: $("select[name = 'state']").val(),
                                },
                                page: {
                                    curr: 1
                                }
                            });
                        }
                    );
                }

                fun1.call(layuithis)
            }
        );

        //添加考场
        $('#bsroomadd').click(function () {
            openLayer('添加考场', '/Do/BS/addroom', '80%', '90%');
        });

        //修改考场
        $('#bsroomedit').click(function () {
            //EditInfo('修改考场', '/Do/BS/editroom?_x=2015', '80%', '90%');
            var url = '/Do/BS/editroom?_x=2015';

            var id = '';
            var checkRows = layui.table.checkStatus('roomTable').data;
            var count = checkRows.length;

            if (count < 1) {
                layer.msg('请选择一条信息',{icon:7,time:2000});
            } else if (count > 1) {
                layer.msg('只能选择一条信息',{icon:7,time:2000});
            } else {
                $(checkRows).each(function (index, itme) {
                    id = itme.ids.replace('cb_', '');
                });
                openLayer('修改考官信息', url + '&id=' + id, '80%', '98%');
            }
        });

        //删除考场
        $('#bsroomdel').click(function () {
            layer.confirm('删除以后不能恢复，确定要删除吗？', {
                btn: ['是', '否']
            }, function () {
                //DelInfo('/Do/BS/DelRoomAction');
                var checkRows = layui.table.checkStatus('roomTable').data;
                var id = '';
                var count = checkRows.length;

                if (count < 1) {
                    layer.msg('请选择一条信息',{icon:7,time:2000});
                } else if (count > 1) {
                    layer.msg('只能选择一条信息',{icon:7,time:2000});
                } else {
                    $(checkRows).each(function (index, itme) {
                        id = itme.ids.replace('cb_', '');
                    });
                    $.post("/Do/BS/DelRoomAction", {id: id}, function (result) {
                        if (result.state) {
                            layer.alert(result.Message, {icon: 1});
                            tavkeIns.reload('roomTable', {
                                page: {
                                    curr: 1
                                }
                            });
                        } else {
                            layer.alert(result.Message, {icon: 2});
                        }
                    }, "JSON");
                }
            }, function () {
            });
        });

        var tavkeIns;
        let layuithis;
        layui.use('table',function () {
            var table = layui.table;
            layuithis = this;

            tavkeIns = table.render({
                id:'roomTable',
                elem:'#tablelist',
                url:'/Do/BS/getroomsLayuiJson',
                height:'full',
                cols:[[
                    {type:'checkbox',fixed:'left'},
                    {field:'id',title:'序号',fixed:'left',sort:true,width:80},
                    {field: 'name',title: '考场名称',fixed: 'left',sort: true},
                    {field: 'nickname',title: '考场别名',fixed: 'left',sort: true},
                    {field: 'startnum',title: '作为开始编号',fixed: 'left',sort: true,width: 120},
                    {field: 'allcount',title: '有效座位数量',fixed: 'left',sort: true,width: 120},
                    {field: 'address',title: '考场地址',sort: true,width:600},
                    {field: 'state',title: '状态',fixed: 'right',sort: true,width: 80},
                    {field: 'priority',title: '优先级',fixed: 'right',sort: true,width: 80}
                ]],
                page:true
            });
        });
    });
    $(function () {


    });
    function getList() {
        $('#page').myPagination({
            cssStyle: "pagination",
            ajax: {
                on: true,
                url: '/Do/BS/getrooms',
                param: $('#sform').serialize(),
                dataType: 'html',
                callback: function (data) {
                    $('#result').html(data);
                }
            }
        });
    }
</script>
</body>
</html>